package org.god.core;

import java.util.Map;

public class SqlSessionFactory {

   //事务管理器
   Transaction transaction;
   //数据源


   //Mapper sql
    Map<String, MappedStatement> mappedStatement;

    public SqlSessionFactory() {
    }
    public SqlSessionFactory(Transaction transaction, Map<String, MappedStatement> mappedStatement) {
        this.transaction = transaction;
        this.mappedStatement = mappedStatement;
    }

    public Transaction getTransaction() {

        return transaction;
    }

    public void setTransaction(Transaction transaction) {
        this.transaction = transaction;
    }

    public Map<String, MappedStatement> getMappedStatement() {
        return mappedStatement;
    }

    public void setMappedStatement(Map<String, MappedStatement> mappedStatement) {
        this.mappedStatement = mappedStatement;
    }
    public SqlSession openSession() {
        transaction.openConnection();
        SqlSession sqlSession = new SqlSession(this);
        return sqlSession;
    }

    @Override
    public String toString() {
        return "SqlSessionFactory{" +
                "transaction=" + transaction +
                ", mappedStatement=" + mappedStatement +
                '}';
    }
}
